package com.qyhl.webtv.module_live.teletext.summary;

import android.graphics.Color;
import android.os.Bundle;
import androidx.annotation.Nullable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.method.ScrollingMovementMethod;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.qyhl.webtv.basiclib.utils.StringUtils;
import com.qyhl.webtv.commonlib.utils.view.ViewPageFragment;
import com.qyhl.webtv.module_live.R;
import com.qyhl.webtv.module_live.R2;
import com.umeng.analytics.MobclickAgent;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * Created by qyhl on 2017/7/20.
 * 图文描述
 */

public class TeleTextSummaryFragment extends ViewPageFragment {
    @BindView(R2.id.summary)
    TextView summaryText;

    private String summary;

    public void setSummary(String summary) {
        this.summary = summary;
    }

    public TeleTextSummaryFragment() {

    }

    public static TeleTextSummaryFragment newInstance(String summary) {
        TeleTextSummaryFragment fragment = new TeleTextSummaryFragment();
        fragment.setSummary(summary);
        return fragment;
    }


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if (rootView == null) {
            rootView = inflater.inflate(R.layout.live_fragment_teletext_summary, container, false);
            ButterKnife.bind(this, rootView);
        }
        init();
        ViewGroup parent = (ViewGroup) rootView.getParent();
        if (parent != null) {
            parent.removeView(rootView);
        }
        return rootView;
    }


    //初始化
    private void init() {
        if (StringUtils.isEmpty(summary)) {
            summaryText.setText("暂无任何内容！");
        } else {
            summaryText.setMovementMethod(ScrollingMovementMethod.getInstance());
            summaryText.setText(summary);
        }
    }


    @Override
    public void onResume() {
        super.onResume();
        //umeng
        MobclickAgent.onPageStart("图文直播介绍");
        MobclickAgent.onResume(getContext());
    }


    @Override
    public void onPause() {
        super.onPause();
        //umeng
        MobclickAgent.onPageEnd("图文直播介绍");
        MobclickAgent.onPause(getContext());
    }


}

